package com.dietdroid;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;

import android.content.Context;

public class HistoryData implements Serializable {

    /**
	 * 
	 */
    private static final long                                serialVersionUID = 7477270867176537714L;
    private HashMap<String, ArrayList<HistoryFoodItemModel>> history;

    public HistoryData() {

        history = new HashMap<String, ArrayList<HistoryFoodItemModel>>();
    }

    public ArrayList<HistoryFoodItemModel> getHistoryForDate(int month,
            int year, int day) {

        String date = month + "/" + day + "/" + year;
        return history.get(date);

    }

    public void addHistoryForToday(FoodItem item, double servings) {
        final Calendar c = Calendar.getInstance();
        addHistoryForDate(c.get(Calendar.MONTH), c.get(Calendar.YEAR),c.get(Calendar.DAY_OF_MONTH), item,
                servings);
    }

    public void addHistoryForDate(int month, int year, int day, FoodItem item,
            double servings) {
        String date = month + "/" + day + "/" + year;
        ArrayList<HistoryFoodItemModel> history_list = history.get(date);
        if (history_list == null) {
            history_list = new ArrayList<HistoryFoodItemModel>();
            history_list.add(new HistoryFoodItemModel(item, servings));
            history.put(date, history_list);
        } else {
            history_list.add(new HistoryFoodItemModel(item, servings));
            history.put(date, history_list);
        }

    }

}
